// 封装菜单管理相关接口
import request from '@/utils/request'
import type { MenuByRoleResponse,MenuListResponse,MenuAddRequest} from '@/types/permission/menu'

// 根据角色ID查询菜单列表
export const getMenuListByRoleIdAPI = (roleId: number)  => {
    return request.get<any, MenuByRoleResponse>(`/admin/acl/permission/toAssign/${roleId}`)
}

// 为相应的角色分配权限
export const assignPermissionAPI = (roleId: number, permissionId: number[]) => {
    return request.post<any, any>(`/admin/acl/permission/doAssign?roleId=${roleId}&permissionId=${permissionId}`, )
}

// 获取全部菜单列表
export const getAllMenuListAPI = () => {
    return request.get<any, MenuListResponse>(`/admin/acl/permission`)
}

// 新增菜单
export const addMenuAPI = (data: MenuAddRequest) => {
    return request.post<any, any>(`/admin/acl/permission/save`, data)
}

// 修改菜单
export const updateMenuAPI = (data: MenuAddRequest) => {
    return request.put<any, any>(`/admin/acl/permission/update`, data)
}

// 删除菜单
export const deleteMenuAPI = (id: number) => {
    return request.delete<any, any>(`/admin/acl/permission/remove/${id}`)
}